package com.starmark.gateway.springcloud.provider.response;

import lombok.Data;
import org.springframework.http.HttpStatus;

import java.io.Serializable;
import java.time.Instant;

/**
 * 返回信息
 *
 * @author starmark
 * <p>
 * 2018年4月25日
 */
@Data
public class Response implements Serializable {
    protected int  code;
    protected String msg;

    protected long timestamp;

    public Response(int  code, String msg) {
        this.code = code;
        this.msg = msg;
        this.timestamp =Instant.now().toEpochMilli();
    }

    public Response(HttpStatus code, String msg) {
        this.code = code.value();
        this.msg = msg;
        this.timestamp =Instant.now().toEpochMilli();
    }

    public Response(HttpStatus code) {
        this.code = code.value();
        this.msg = code.getReasonPhrase();
        this.timestamp =Instant.now().toEpochMilli();
    }

    public Response() {

        this.timestamp =Instant.now().toEpochMilli();
    }


}